
// 回答页面主体js代码
var answerVerify = false;
$(function(){
	// 返回顶部按钮代码 [start]
	$(window).scroll(function(){
		var ws = $(window).scrollTop();
		if( ws > 100){
			$('#back_top').show();
		}else{
			$('#back_top').hide();
		}
	});
	$('#back_top').click(function(){
		$(window).scrollTop(0);
		return false;
	});
	// 返回顶部按钮代码 [end]
	
	// 提交回答按钮事件
	$('#submit').on({
		mouseover:function(){
			$(this).css('backgroundPosition','100% -412px').parent().css({
				backgroundColor:'$44cc11',backgroundPosition:'0 -412px'
			});
		},
		mouseout:function(){
			$(this).css('backgroundPosition','100% -378px').parent().css({
				backgroundColor:'$44cc11',backgroundPosition:'0 -378px'
			});
		},
		click:function(){
			var cont = $('#textarea').val();
			var preg = /\s+/ig;
			cont = cont.replace(preg,'');
			if(cont == ''){
				$('#textarea').css('backgroundColor','#f00');
				setTimeout(function(){
					$('#textarea').css('backgroundColor','#fff');
				},100);
				answerVerify = false;
			}else if(!userid){
				$.post("?c="+CONTROL+"&m=addCookie",{qid:qid},function (data){
					if(data){
						$('#rightTopLogin').trigger('click');
					}
				},'json');
				answerVerify = false;
			}else{
				answerVerify = true;
			}
		}
	});
	// 表单提交事件
	$('form[name="answerForm"]').submit(function(){
		if(answerVerify){
			return true;
		}else{
			return false;
		}
	});

});









